<?php

include('header.php');
$smarty->assign('media', siteinfo('media'));
include('bottom_banners.php');
include('chat.php');
include('sidebar_banners.php');


if(($_GET['sr']) =='custom') {
	$username = mres(($_GET['memb_filter_term']));
        $user =" ";
        $ime = " ";
	$sortiranje = mres(($_GET['memb_filter_sort']));
        
        $username = explode(" ", $username);
   
    $ukupno_imena = count($username);
    for ($i = 0; $i < $ukupno_imena; $i++) {
        if ($i == ($ukupno_imena-1)) {
            $user.=" username like '%$username[$i]%'";
            $ime.=" ime like '%$username[$i]%'";
        } else {
            $user.=" username like '%$username[$i]%' or ";
            $ime.=" ime like '%$username[$i]%' or ";
        }
    }
    
	$paginatorClanovi = new Paginator;
	$paginatorClanovi->items_total = totalSearchClanovi($user,$ime);
	$paginatorClanovi->mid_range = 5;
	$paginatorClanovi->paginate();
	$smarty->assign('paginationClanovi', $paginatorClanovi->display_pages());
	$clanovi = getSearchClanoviList($user, $ime, $sortiranje, $paginatorClanovi->limit);
	$smarty->assign('clanovi', $clanovi);
}else {
	$paginatorClanovi = new Paginator;
	$paginatorClanovi->items_total = totalClanovi();
	$paginatorClanovi->mid_range = 5;
	$paginatorClanovi->paginate();
	$smarty->assign('paginationClanovi', $paginatorClanovi->display_pages());
	$clanovi = getClanoviList($paginatorClanovi->limit);
	$smarty->assign('clanovi', $clanovi);
}
$smarty->display('clanovi.tpl');
include('footer.php');

?>
